# Contributor: Bradley J Chambers <brad.chambers@gmail.com>
# Maintainer: Bradley J Chambers <brad.chambers@gmail.com>
pkgname=pcl
pkgver=1.8.1
pkgrel=6
pkgdesc="Point Cloud Library (PCL)"
url="https://github.com/PointCloudLibrary/pcl"
arch="all !x86 !s390x !mips !mips64" # tests fails on x86 and s390x, blocked by eigen on mips
license="BSD-3-Clause"
makedepends="cmake eigen-dev boost-dev flann-dev"
subpackages="$pkgname-dev"
_gtestver=1.8.0
source="$pkgname-$pkgver.tar.gz::https://github.com/PointCloudLibrary/$pkgname/archive/$pkgname-$pkgver.tar.gz
	release-$_gtestver.tar.gz::https://github.com/google/googletest/archive/release-$_gtestver.tar.gz
	gcc8.patch"
builddir="$srcdir/$pkgname-$pkgname-$pkgver"

build() {
	mkdir build && cd build

	local disable_segtests=
	case "$CARCH" in
		ppc64le | aarch64) disable_segtests="-DBUILD_tests_segmentation=OFF"
	esac
	# Five tests are disabled below. This is in keeping with PCL's own
	# Appveyor configuration
	# (https://github.com/PointCloudLibrary/pcl/blob/master/.appveyor.yml),
	# and is due to a list of test failures that are documented in issues
	# #1702, #1719, #1921, and #2136.
	cmake .. \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_BUILD_TYPE=None \
		-DWITH_CUDA=OFF \
		-DWITH_DAVIDSDK=OFF \
		-DWITH_DSSDK=OFF \
		-DWITH_ENSENSO=OFF \
		-DWITH_FZAPI=OFF \
		-DWITH_LIBUSB=OFF \
		-DWITH_OPENGL=OFF \
		-DWITH_OPENNI=OFF \
		-DWITH_OPENNI2=OFF \
		-DWITH_PCAP=OFF \
		-DWITH_PNG=OFF \
		-DWITH_QHULL=OFF \
		-DWITH_QT=OFF \
		-DWITH_VTK=OFF \
		-DBUILD_global_tests=ON \
		-DBUILD_examples=OFF \
		-DBUILD_tools=ON \
		-DBUILD_apps=OFF \
		-DBUILD_tests_common=OFF \
		-DBUILD_tests_features=OFF \
		-DBUILD_tests_filters=OFF \
		-DBUILD_tests_io=OFF \
	$disable_segtests \
		-DBUILD_tests_registration=OFF \
		-DGTEST_SRC_DIR=$srcdir/googletest-release-$_gtestver/googletest \
		-DGTEST_INCLUDE_DIR=$srcdir/googletest-release-$_gtestver/googletest/include
	make
}

package() {
	cd "$builddir"/build
	make DESTDIR="$pkgdir" install
}

check() {
	cd "$builddir"/build
	ctest -E a_octree_test # Fails on drone-ci aarch64
}

sha512sums="9e7c87fb750a176712f08d215a906012c9e8174b687bbc8c08fa65de083b4468951bd8017b10409015d5eff0fc343885d2aae5c340346118b1a251af7bdd5cd7  pcl-1.8.1.tar.gz
1dbece324473e53a83a60601b02c92c089f5d314761351974e097b2cf4d24af4296f9eb8653b6b03b1e363d9c5f793897acae1f0c7ac40149216035c4d395d9d  release-1.8.0.tar.gz
16b3ca34fe31a3a7c9b1eefe818e963eda483b8d18a40e766306aaa653dd5d6072cd5dacb16c49e8905309ba179d0defb90c42aad1a3fb6c2d9fbde9b12e9ebc  gcc8.patch"
